package lesson2;

public class Fibonacci {
	public static void main(String[] args) {
		//find the sum of first n fibonacci numbers
		//fibonacci numbers = 0,1,1,2,3,5,8,13,.... .. :(
		//formula: F(n) = F(n-1) + F(n-2)
		
		int n = 12;
		
		int preprevious = 0;
		int previous = 1;
		
		int nextNumber = 0;
		System.out.println( 1 + " " + preprevious);
		System.out.println( 2 + " " +previous);
		
		int sum = preprevious + previous;
		
		for(int i = 3; i <= n; i++)
		{
			nextNumber = preprevious  + previous;
			preprevious = previous;
			previous = nextNumber;
			sum = sum + nextNumber;
			System.out.println(i + " " + nextNumber);
		}
		
		System.out.println("sum of all above is = " + sum);
		
		
	}
}
